﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using LPV_POS.Module;

namespace LPV_POS.mh_pos.mh_danhmuc
{
    public partial class mh_cauhinhdiem : DevExpress.XtraEditors.XtraForm
    {
        thuvien tv;
        public mh_cauhinhdiem()
        {
            InitializeComponent();
        }

        private void bton_thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void bton_chọn_Click(object sender, EventArgs e)
        {
            int _ketqua = -1;
            double _tien = 0;
            double.TryParse(txt_tien.Text.Trim(), out _tien);
            tv = new thuvien();
            _ketqua = tv.SP_Update("sp_cauhinhdiem", new string[] { "@flag", "@tien" }, new object[] {2, _tien });
            if (_ketqua <= -1)
            {
                Mod_messagebox mess = new Mod_messagebox();
                mess.messagebox_pos("Thông báo", "Lưu không thành công", loaithongbao.canhbao.GetHashCode());
            }
            else
            {
                Mod_messagebox mess = new Mod_messagebox();
                mess.messagebox_pos("Thông báo", "Lưu thành công", loaithongbao.canhbao.GetHashCode());
            }

        }

        private void mh_cauhinhdiem_Load(object sender, EventArgs e)
        {
            DataTable tb;
            tv = new thuvien();
            tb = tv.SP_SelectDataTable("sp_cauhinhdiem", new string[] { "@flag" }, new object[] { 1 });
            if (tb == null)
                return;
            if (tb.Rows.Count > 0)
            {
                txt_tien.Text = tb.Rows[0]["TONG_TIEN"] + "";
            }
            else
                txt_tien.Text = "0";
        }

        private void bton_tien_Click(object sender, EventArgs e)
        {
            string _sotien = new cpublic().loadformso_point(470, 270);
            if (_sotien  != "")
                txt_tien.Text = _sotien;
        }
    }
}